package com.buptse.controller;


import com.buptse.service.InformationService;
import com.buptse.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/home")
@CrossOrigin
public class HomeController {

    @Autowired
    private InformationService informationService;
    @Autowired
    private UserService userService;

    //地图展示
    @RequestMapping("/map")
    @ResponseBody
    @CrossOrigin
    public List<Map<String,Object>> getEarthQuakeMap(){
        List<Map<String,Object>> mapList=informationService.getEarthQuakeMap();
        return mapList;
    }

    //登录
    @RequestMapping("/login")
    @ResponseBody
    @CrossOrigin
    public Map<String,Object> login(String account,String password){

        return userService.login(account,password);
    }

    @RequestMapping("visitorLogin")
    @ResponseBody
    public Map<String,String> visitorLogin(){
        Map<String, String> map = new HashMap<>();
        map.put("stat","visitor");
        return map;
    }
}
